<?php

namespace IMT\ServicesBundle\Models\Event;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

class EventOperationResponse
{
	/**
	 * @Soap\ComplexType("string", nillable=true)
	 */
	private $message;
	
	/**
	 * @Soap\ComplexType("int")
	 */
	private $code;
	
	/**
	 * @Soap\ComplexType("string", nillable=true)
	 */
	private $details;
	
	/**
	 * @Soap\ComplexType("\IMT\EventBundle\Entity\Event", nillable=true)
	 */
	private $result;
	
	public function __construct($result)
	{
		if($result instanceof \Exception){
			$this->code = $result->getCode();
			$this->message = $result->getMessage();
			$this->details = ($result->getCode() != -1) ? $result->__toString() : NULL;
			$this->result = NULL;
		} else {
			$this->code = 1;
			$this->message = NULL;
			$this->details = NULL;
			$this->result = $result;
		}
	}
}